package com.deyuanyun.pic.pipe.controller.vo;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pipe.domain.Protection;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.util.ArrayList;
import java.util.List;

/**
 * 水工保护信息
 */
public class ProtectionVO extends BaseVO<Protection> {

    // 管道名称
    private String pipeLineName;
    // 水工保护名称
    private String protectionName;
    // 水工保护编号
    private String protectionNumber;
    // 起点绝对距离(m)
    private String fromMileage;
    // 起点相对最近参考点
    private String fromReference;
    // 起点相对最近参考点距离(m)
    private String fromReferenceDistance;
    // 终点绝对距离(m)
    private String toMileage;
    // 终点相对最近参考点
    private String toReference;
    // 终点相对最近参考点距离(m)
    private String toReferenceDistance;
    // 位置描述
    private String locationDescription;
    // 材料
    private String materialType;
    // 水工保护类型
    private String protectionType;
    // 构筑物尺寸（m）
    private String protectionSize;
    // 水工保护状态
    private String state;
    // 投用日期
    private String inserviceDate;
    // 施工单位
    private String assemblyCompany;
    // 监理单位
    private String inspectingCompany;
    // 检测单位
    private String testingcompany;

    // 链接GIS结果表
    private String gisId;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getProtectionName() {
        return protectionName;
    }

    public void setProtectionName(String protectionName) {
        this.protectionName = protectionName;
    }

    public String getProtectionNumber() {
        return protectionNumber;
    }

    public void setProtectionNumber(String protectionNumber) {
        this.protectionNumber = protectionNumber;
    }

    public String getFromMileage() {
        return fromMileage;
    }

    public void setFromMileage(String fromMileage) {
        this.fromMileage = fromMileage;
    }

    public String getFromReference() {
        return fromReference;
    }

    public void setFromReference(String fromReference) {
        this.fromReference = fromReference;
    }

    public String getFromReferenceDistance() {
        return fromReferenceDistance;
    }

    public void setFromReferenceDistance(String fromReferenceDistance) {
        this.fromReferenceDistance = fromReferenceDistance;
    }

    public String getToMileage() {
        return toMileage;
    }

    public void setToMileage(String toMileage) {
        this.toMileage = toMileage;
    }

    public String getToReference() {
        return toReference;
    }

    public void setToReference(String toReference) {
        this.toReference = toReference;
    }

    public String getToReferenceDistance() {
        return toReferenceDistance;
    }

    public void setToReferenceDistance(String toReferenceDistance) {
        this.toReferenceDistance = toReferenceDistance;
    }

    public String getLocationDescription() {
        return locationDescription;
    }

    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription;
    }

    public String getMaterialType() {
        return materialType;
    }

    public void setMaterialType(String materialType) {
        this.materialType = materialType;
    }

    public String getProtectionType() {
        return protectionType;
    }

    public void setProtectionType(String protectionType) {
        this.protectionType = protectionType;
    }

    public String getProtectionSize() {
        return protectionSize;
    }

    public void setProtectionSize(String protectionSize) {
        this.protectionSize = protectionSize;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getInserviceDate() {
        return inserviceDate;
    }

    public void setInserviceDate(String inserviceDate) {
        this.inserviceDate = inserviceDate;
    }

    public String getAssemblyCompany() {
        return assemblyCompany;
    }

    public void setAssemblyCompany(String assemblyCompany) {
        this.assemblyCompany = assemblyCompany;
    }

    public String getInspectingCompany() {
        return inspectingCompany;
    }

    public void setInspectingCompany(String inspectingCompany) {
        this.inspectingCompany = inspectingCompany;
    }

    public String getTestingcompany() {
        return testingcompany;
    }

    public void setTestingcompany(String testingcompany) {
        this.testingcompany = testingcompany;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    public void fromDomain(Protection domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 水工保护名称
        this.protectionName = domain.getProtectionName();
        // 水工保护编号
        this.protectionNumber = domain.getProtectionNumber();
        // 起点绝对距离(m)
        this.fromMileage = NumberFormat.format(domain.getFromMileage(), NumberFormat.FMT_PLACES3);
        // 起点相对最近参考点
        this.fromReference = domain.getFromReference();
        // 起点相对最近参考点距离(m)
        this.fromReferenceDistance = NumberFormat.format(domain.getFromReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 终点绝对距离(m)
        this.toMileage = NumberFormat.format(domain.getToMileage(), NumberFormat.FMT_PLACES3);
        // 终点相对最近参考点
        this.toReference = domain.getToReference();
        // 终点相对最近参考点距离(m)
        this.toReferenceDistance = NumberFormat.format(domain.getToReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 位置描述
        this.locationDescription = domain.getLocationDescription();
        // 材料
        this.materialType = CodeUtil.getName(domain.getMaterialType());
        // 水工保护类型
        this.protectionType = CodeUtil.getName(domain.getProtectionType());
        // 构筑物尺寸（m）
        this.protectionSize = NumberFormat.format(domain.getProtectionSize());
        // 水工保护状态
        this.state = CodeUtil.getName(domain.getState());
        // 投用日期
        this.inserviceDate = DateFormat.format(domain.getInserviceDate());
        // 施工单位
        this.assemblyCompany = domain.getAssemblyCompany();
        // 监理单位
        this.inspectingCompany = domain.getInspectingCompany();
        // 检测单位
        this.testingcompany = domain.getTestingcompany();
        // gis地址
        this.gisId = domain.getGisId();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getCreateRemark());
    }

    public Page<ProtectionVO> fromDomainList(Page<Protection> domainList) {
        Page<ProtectionVO> list = new Page<ProtectionVO>();
        for (Protection protection : domainList) {
            ProtectionVO protectionVO = new ProtectionVO();
            protectionVO.fromDomain(protection);
            list.add(protectionVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}